﻿using UnityEngine;

namespace Core.Setting
{
    public interface IScreenPlatform
    {
        ScreenOrientation Orientation { get; }
        bool IsPortrait();
        bool IsLandscape();

        void Awake(ScreenSetting owner);

        void Set(ESceneOrientation ori);
    }

    public abstract class AbstractScreenPlatform : Component, IScreenPlatform
    {
        public ScreenSetting Scrn { get; protected set; }

        public ScreenOrientation Orientation { get; protected set; }

        public bool IsPortrait()
        {
            return Orientation == ScreenOrientation.Portrait ||
                Orientation == ScreenOrientation.PortraitUpsideDown;
        }

        public bool IsLandscape()
        {
            return Orientation == ScreenOrientation.LandscapeLeft ||
                Orientation == ScreenOrientation.LandscapeRight;
        }

        public virtual void Awake(ScreenSetting owner)
        {
            Scrn = owner;
        }


        public override void Dispose()
        {
            if (IsDisposed) return;
            base.Dispose();
        }


        public virtual void Set(ESceneOrientation ori)
        {
        }

    }

}
